#ifndef __LAMEBITMAP_H__
#define __LAMEBITMAP_H__

#include "LAME.h"

#define DECLARE_BLITTER(name,special) \
	void name (short16 *s, short16 *d, int len, int special) 

DECLARE_BLITTER(linear_blit,none);
DECLARE_BLITTER(sprite_blit_pink,none);
DECLARE_BLITTER(color_blit,color);
DECLARE_BLITTER(sprite_gray_blit,color);
DECLARE_BLITTER(color50_blit,color);

class LAMEBitmap  
{
protected:
	short16 *data;
	int w, h;
	int pitch;

public:
	LAMEBitmap();
	virtual ~LAMEBitmap();

	int width()	 {return w;}
	int height() {return h;}
	short16 *row(int y) {return data + y*pitch;}

	void load(const TCHAR *filename);
	void loadFromMem(char *temp);
	void create(int w, int h);
	void destroy();

	void clear(short16 color);

	void hLine(int x1, int y, int x2, short16 color);
	void hLineDarken(int x1, int y, int x2);
	void hLineAlpha50(int x1, int y, int x2, short16 color);
	void vLine(int x, int y1, int y2, short16 color);
	void vLineAlpha50(int x, int y1, int y2, short16 color);

	void line(int x1, int y1, int x2, int y2, short16 color);

	void rect(int x1, int y1, int x2, int y2, short16 color);
	void rectFill(int x1, int y1, int x2, int y2, short16 color);
	void rectRectFill(int x1, int y1, int x2, int y2, short16 border, short16 fill)
	{
		rectFill(x1,y1,x2,y2,fill);
		rect(x1,y1,x2,y2,border);
	}
	void rectFillFaded(int x1, int y1, int x2, int y2, short16 color1, short16 color2);
	void rectFillDarkFaded(int x1, int y1, int x2, int y2, short16 color)
	{
		rectFillFaded(x1,y1,x2,y2,color, darkenColor(color));
	}

	void circle(int x, int y, int radius, short16 color);
	void circlefill(int x, int y, int radius, short16 color);

	void rectFillDarken(int x1, int y1, int x2, int y2);
	void putPixel(int x, int y, short16 color);
	short16 getPixel(int x, int y);
	void blitTo(LAMEBitmap &dest, int dx, int dy, int sx, int sy, int sw, int sh, void (*blitter)(short16*,short16*,int,int)=linear_blit, int special=-1, int doclip=1);
	void blitToCoord(LAMEBitmap &dest, int dx, int dy, void (*blitter)(short16*,short16*,int,int)=linear_blit, int special=-1)
	{
		blitTo(dest,dx,dy,0,0,w,h,blitter,special,1);
	}
	void blitToCoordCenter(LAMEBitmap &dest, int dx, int dy, void (*blitter)(short16*,short16*,int,int)=linear_blit, int special=-1)
	{
		blitToCoord(dest,dx-w/2,dy-h/2,blitter,special);
	}
	void rotateSprite(LAMEBitmap *sprite, int x, int y, int angle, int scale);

	void drawText(const TCHAR *text, int x, int y, short16 color = 0, int font=0, void (*blitter)(short16*,short16*,int,int)=color_blit,int xmax=0xffff);
	void drawTextCenter(const TCHAR *text, int x, int y, short16 color, int font=0);
	void drawTextShadow(const TCHAR *text, int x, int y, short16 color=0xffff, short16 shadowColor=0, int font=0);
	void drawTextShadowCenter(const TCHAR *text, int x, int y, short16 color=0xffff, short16 shadowColor=0, int font=0);
	void drawTextContrastCenter(const TCHAR *text, int x, int y, short16 color=0xffff, short16 shadowColor=0, int font=0);
	void drawTextContrast(const TCHAR *text, int x, int y, short16 color=0xffff, short16 shadowColor=0, int font=0);
};

#endif //__LAMEBITMAP_H__